package com.wcf.service;

import com.wcf.model.User;
import com.wcf.service.facade.UserServiceFacade;
import com.wcf.service.impl.Userservice;
import org.springframework.beans.factory.annotation.Autowired;

import javax.jws.WebService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by hadoop on 2016/1/9.
 */
@WebService
public class UserServiceImpl implements UserServiceFacade {
    private static Map<String,User> users=null;

    @Autowired
    private static Userservice userservice;

    private static void init(){
        users = new HashMap<String,User>();
        List<User> list = userservice.findAllUser();

        for (User user : list) {
            users.put(user.getName(),user);
        }
    }

    @Override
    public User getUserByName(String name) {
        User user=null;
        if(users==null){
            user = users.get(name);
        }
        return user;
    }

    @Override
    public void setUser(User user) {
    }
}
